<%-- 
    Document   : userInfo
    Created on : Dec 5, 2011, 1:30:21 AM
    Author     : Michael
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.Enumeration"%>
<% if(session.getAttribute("LoggedIn")==null)
       {
    response.sendRedirect("index.html");
    return;
        }

%>
<%
    Enumeration<String> fields = request.getParameterNames();
    String query = "UPDATE customer SET ";
    while(fields.hasMoreElements())
    {
        String next = fields.nextElement();
        query += (next + "='" + request.getParameter(next) + "'");
        if(fields.hasMoreElements())
        {
            query += ", ";
        }
    }
    query += " WHERE CustomerID='" + session.getAttribute("UserID") + "'";
    
    Connection conn = null;
    try
    {
        conn = new DBClasses.GetConnection().getConnection();
        Statement stmt = conn.createStatement();
        stmt.execute(query);
    }
    
    catch(Exception e) {
    e.printStackTrace();
    response.sendRedirect("profile.jsp");
    }
    
    finally
    {
        try {
        conn.commit();
        conn.close();
        response.sendRedirect("profile.jsp");
               }
        catch(Exception e) { e.printStackTrace(); response.sendRedirect("profile.jsp"); }
        
    }
%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

